package com.ebs.md.api.deal;

/**
 * Revision Author:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/deal/BasicDeal.java $
 *  $Revision: #5 $
 *  $DateTime: 2012/08/27 13:51:59 $
 *  $Change: 114224 $
 *  $Author: Aviad.Yosef $
 */

import java.util.Calendar;

import com.ebs.md.api.IProduct;
import com.ebs.md.api.Rate;


public class BasicDeal
implements IDeal
{
	// gened via Eclipse
	private static final long serialVersionUID = 3884058478073006933L;

	protected String    dealId;   // pk 1#2
	protected DealSide  dealSide; // pk 2#2

	protected Calendar  dealTime;
	
	protected IProduct product;
	protected Rate     rate;
	protected long     amount;
	protected DealSideAction dealSideAction;
	
	protected Integer  firmId; // can be null, if original value is 0...
	protected String   floorCode;
	protected String   orderId;  // the quoteId.
	
	protected Integer  cpFirmId; // can be null, if original value is 0...
	protected String   cpFloorCode;
	protected String   cpOrderId;
	
	
	
	public BasicDeal(String dealId, DealSide dealSide, Calendar dealTime,
			IProduct product, Rate rate, long amount,
			DealSideAction dealSideAction
			, Integer    firmId, String   floorCode, String   orderId
			, Integer  cpFirmId, String cpFloorCode, String cpOrderId
			) {
		super();
		this.dealId = dealId;
		this.dealSide = dealSide;
		this.dealTime = dealTime;
		this.product = product;
		this.rate = rate;
		this.amount = amount;
		this.dealSideAction = dealSideAction;
		
		this  .firmId    =   firmId;
		this  .floorCode =   floorCode;
		this  .orderId   =   orderId;
		
		this.cpFirmId    = cpFirmId;
		this.cpFloorCode = cpFloorCode;
		this.cpOrderId   = cpOrderId;
	}
	public String getId() {
		return dealId;
	}
	public DealSide getDealSide() {
		return dealSide;
	}
	public IProduct getProduct() {
		return product;
	}
	public Rate getRate() {
		return rate;
	}
	public long getAmount() {
		return amount;
	}
	public DealSideAction getDealSideAction() {
		return dealSideAction;
	}
	public String getOrderId() {
		return orderId;
	}
	public String getDealId() {
		return dealId;
	}
	public Calendar getDealTime() {
		return dealTime;
	}
	public Integer getFirmId() {
		return firmId;
	}
	public String getFloorCode() {
		return floorCode;
	}
	public Integer getCPFirmId() {
		return cpFirmId;
	}
	public String getCPFloorCode() {
		return cpFloorCode;
	}
	public String getCPOrderId() {
		return cpOrderId;
	}
	@Deprecated
	public String getOtherSideOrderId() {
		return cpOrderId;
	}
	public Calendar getTime() {
		return dealTime;
	}

	public long getTimestamp() {
		return dealTime.getTimeInMillis();
	}
	
	// generated by Eclipse on "dealId" + "dealSide"
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dealId == null) ? 0 : dealId.hashCode());
		result = prime * result
				+ ((dealSide == null) ? 0 : dealSide.hashCode());
		return result;
	}
	// generated by Eclipse on "dealId" + "dealSide"
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BasicDeal other = (BasicDeal) obj;
		if (dealId == null) {
			if (other.dealId != null)
				return false;
		} else if (!dealId.equals(other.dealId))
			return false;
		if (dealSide == null) {
			if (other.dealSide != null)
				return false;
		} else if (!dealSide.equals(other.dealSide))
			return false;
		return true;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		
		sb.append(  "dealId=");
		sb.append(   dealId);
		sb.append(", dealSide=");
		sb.append(   dealSide);
		sb.append(", amount=");
		sb.append(   amount);
		sb.append(", rate=");
		sb.append(   rate);
		sb.append(", dealTime=");
		if ( dealTime == null ) {
			sb.append( "null");
		} else {
			sb.append(  dealTime.getTime());
		}
		
		return sb.toString();
	}
	
	
}
